package app.android.com.wuandroidapp.playair;

import java.io.InputStream;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.RectF;

import app.android.com.wuandroidapp.R;

public class MyAir {

	Bitmap bitmap;// 图像
	int width, height;// 飞机的尺寸
	float x, y;// 出现的位置

	float screenWidth, scrreenHeight;// 屏幕大小
	boolean isLive = true;
	Context context;

	public MyAir(Context context, int resourceID) {

		this.context=context;
		// TODO Auto-generated constructor stub
		// 将图像专场Bitmap
		InputStream is = context.getResources().openRawResource(resourceID);
		bitmap = BitmapFactory.decodeStream(is);

		width = bitmap.getWidth();
		height = bitmap.getHeight();


	}

	public void init(int screenWidth, int scrreenHeight) {
		this.screenWidth = screenWidth;
		this.scrreenHeight = scrreenHeight;

		// 计算飞机的位置
		x = (float) (screenWidth - width)/2;
		y = (scrreenHeight - height);
	}

// 绘制自身

	public void draw(Canvas canvas) {
		if(isLive){
			canvas.drawBitmap(bitmap, x, y, null);
		}else{
			//结束
		}
	}
	public MyBullet myBullet(){
		MyBullet mBullet=new MyBullet(context, R.mipmap.bullet, x+width/2, y,-10);
		return mBullet;

	}

	public void move(float x,float y) {
		this.x=x-width/2;
		this.y=y-height/2;
	}

	public RectF getBound(){
		RectF rf=new RectF(x,y,x+width,y);
		return rf;
	}


}